package com.pas.connectivitystoreconsumer;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Main extends Activity implements OnClickListener {
	private Button _btConsumeServiceSuccess, _btConsumeServiceFailure;
	private TextView _txtResult;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		_btConsumeServiceFailure = (Button) findViewById(R.id.btConsumeServiceFailure);
		_btConsumeServiceSuccess = (Button) findViewById(R.id.btConsumeServiceSuccess);
		_txtResult = (TextView) findViewById(R.id.txtResult);

		_btConsumeServiceFailure.setOnClickListener(this);
		_btConsumeServiceSuccess.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v == _btConsumeServiceFailure) {
			ServiceConsumer consumer = new ServiceConsumer(
					"http://10.0.0.10:8080/ConnectivityStore/ConnectivityStore?action=1");
			_txtResult.setText(consumer.execute());
		} else if (v == _btConsumeServiceSuccess) {
			ServiceConsumer consumer = new ServiceConsumer(
					"http://10.0.0.10:8080/ConnectivityStore/ConnectivityStore?action=1&ni=pablo");
			_txtResult.setText(consumer.execute());
		}

	}
}